package com.qingke;

import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.qingke.pojo.User;

public class MyBatisApp {

	public static void main(String[] args) {
		String mybatisConfig = "mybatis.xml";
		InputStream is = MyBatisApp.class.getClassLoader().getResourceAsStream(mybatisConfig);
		SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is);
		System.out.println("创建SqlSessionFactory成功！");

		SqlSession session = sessionFactory.openSession();
		System.out.println("创建Session成功！");
		
		User user = new User();
		user.setId(5);
		user.setName("wangwu");
		
		//Mapper
		String statement = "com.qingke.mapping.userMapper.insertOne";
		session.insert(statement, user);
		System.out.println("插入成功！");
		session.commit();
		session.close();
	}
	


}
